﻿@model Transport.Models.ForgotPasswordModel
@{
    ViewBag.Title = "";
    Layout = null;
}

@using (Html.BeginForm("ForgotPassWord", "Account", FormMethod.Post, new { id = "frmForgotPassWord" }))
{
    <div id="title">
        Forgot password
    </div>
    <div class="frm">
        @Html.TextBoxFor(m => m.Email, new { value = "", placeholder = "Email Address", @class = "username" })
        @Html.ValidationMessageFor(model => model.Email)
        <input type="submit" value="Send password" class="submit sendPassword" />
        <span id="add-new-address-loading-progress" style="display: none; float: right;padding-top:18px;">
            <img src='@Href("~/Content/images/waiting.gif")' alt="Common.Wait..." />
        </span>
        <div id="ChangePasswordSuccess" style="display:none; clear:both;padding-top:15px;">
            <span style="padding-left: 10px; color: green;">An email has been sent to enable you to reset your password.</span>
        </div>
    </div>
    <div style="padding-left: 4px;">
        <div class="validation-summary-errors" id="divErrors">
        </div>
        @Html.ValidationSummary(true)
    </div>
}
<script type="text/javascript">
    $('#frmForgotPassWord').submit(function (event) {
        $("#add-new-address-loading-progress").show();
        event.preventDefault();
        var prodata = $(this).serialize();
        if ($(this).valid()) {
            $.ajax({
                dataType: "json",
                url: this.action,
                type: this.method,
                data: prodata,
                success: function (result) {
                    $("#add-new-address-loading-progress").hide();
                    if (result == "true") {
                        $("#ChangePasswordSuccess").show(500);
                    }
                    else {
                        $('#divErrors').html(result);
                    }
                }
            });
        }
    });
</script>